package com.code.day05;

import java.util.concurrent.locks.Lock;

public class Dielock implements Runnable{
    private boolean flag;
    public  Dielock(boolean st)
    {
        this.flag = st;
    }

    @Override
    public void run() {
        if(flag)
        {
            synchronized (LockA.lockA){
                System.out.println("LockA...");
                synchronized (LockB.lockB){
                    System.out.println("LockB...");
                }
            }
        }
        else{
            synchronized (LockA.lockA){
                System.out.println("...LockA...");
                synchronized (LockB.lockB){
                    System.out.println("...LockB...");
                }
            }
        }
    }
}
